<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 <script type="text/javascript">
    function show(){
        var f=form;
        var str="";
        alert("姓名   "+f.name.value);
        for(i=0;i<f.sex.length;i++){
            if(f.sex[i].checked){
                str+=f.sex[i].value;
            }
        }
        alert(str);
        str="喜欢的运动：";
        for(i=0;i<f.inst.length;i++){
            if(f.inst[i].checked){
                str+=f.inst[i].value+"、";
            }
        }
        alert(str);
    }
</script>
</head>
<body>
    <form name="form" action="a.html" method="post">
        姓名：<input type="text" name="name" size="6"> <br>
        性别：<input type="radio" name="sex" value="男" checked="checked"> 男
        <input type="radio" name="sex" value="女">女  <br>
        兴趣：<input type="checkbox" name="inst" value="游泳" checked="checked">游泳
        <input type="checkbox" name="inst" value="滑冰">滑冰
        <input type="checkbox" name="inst" value="撸啊撸">撸啊撸
        <input type="checkbox" name="inst" value="编程">编程
        <input type="button" value="显示" onclick="show()">
    </form>
</body>
</html>
